package com.tianji.aigc.service.impl;

import com.tianji.aigc.config.SystemPromptConfig;
import com.tianji.aigc.service.ChatTextService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ChatTextServiceImpl implements ChatTextService {

    private final ChatClient openAiChatClient;
    private final SystemPromptConfig systemPromptConfig;

    @Override
    public String chatText(String question) {
        return this.openAiChatClient
                .prompt()
                .system(promptSystemSpec -> promptSystemSpec.text(systemPromptConfig.getTextSystemMessage().get()))
                .user(question)
                .call()
                .content();
    }
}
